import collections
class Solution(object):
    def minSwaps(self, s):
        if len(s) == 1:
            return 0
        n = len(s)
        c = collections.Counter(s)
        if n % 2:
            if len(c) < 2:
                return -1
            else:
                if not (c['0'] == n // 2 + 1 or c['1'] == n // 2 + 1):
                    return -1
                else:
                    c2 = collections.Counter(s[::2])
                    if c['0'] == n // 2 + 1:
                        return c['0'] - c2['0']
                    else:
                        return c['1'] - c2['1']
        else:
            if c['0'] == n // 2:
                c2 = collections.Counter(s[::2])
                return min(c2['0'], c2['1'])
            else:
                return -1

